#ifndef SYSTEM_MOD_H
#define SYSTEM_MOD_H

#include <klibc/ctype.h>
#include <shell/shell.h>
#include <net/net.h>
#include <fs/vfs.h>

// Costanti di modulo
#define MOD_STATE_OK		1
#define MOD_STATE_DEP_ER	-1
#define MOD_STATE_NULL_ER	-2
#define MOD_STATE_ALRD_ER	-3

#define MOD_OK	0
#define MOD_ER	1

#define MOD_TYPE_DEV_NETWORK	0
#define MOD_TYPE_DEV_GRAPHICS	1
#define MOD_TYPE_DEV_AUDIO		2
#define MOD_TYPE_DEV_HI			3
#define MOD_TYPE_DEV_STORAGE	4
#define MOD_TYPE_FS				13
#define MOD_TYPE_SYSTEM			14
#define MOD_TYPE_UNKNOW			15

struct file
{
	
};

// Funzioni di un modulo
typedef uint32_t (*mod_shut_t)();
typedef uint32_t (*mod_init_t)(char *);
typedef uint8_t	   mod_type_t;
typedef vfs_node_t fdev_t;

// Struttura di un modulo
typedef struct module_p_t
{
	char name[32];
	char author[128];
	char license[128];
	char desc[128];
	// Dipendenze (separate da ' ')
	char dep[512];
	
	uint8_t type;
	uint8_t loaded;
	uint32_t id;
	
	mod_init_t 		init;
	mod_shut_t 		shut;
	
	fdev_t	*dev;
	//fs_t fs; //* <- e' un filesystem
	//net_iface_t net; //* <- e' un interfaccia di rete eth0 wifi0
	//dev_t dev; // <- e' un device driver
	
	struct module_p_t *next;
} module_t;


// Lista dei moduli
module_t *mod_list;
uint32_t mod_id;
char mod_type_strings[16][32];

// Funzioni per i moduli
void mod_init();
void mod_add(module_t *);
void mod_del(module_t *);
void mod_command();

uint8_t mod_check(char *);
uint8_t mod_depok(module_t *);
uint8_t mod_list_save(char *);
uint8_t mod_list_load(char *);

uint32_t mod_get_num();
uint32_t mod_uconfig();
uint32_t mod_initm(module_t *, char *);
uint32_t mod_shutm(module_t *);
uint32_t mod_rwop(struct file *, uint8_t *, uint32_t, uint64_t);
uint32_t mod_ocop(struct file *);

module_t *mod_get(char *);
module_t *mod_get_prev(module_t *);

#endif
